package desktop.playerguide.multichoiceswin;

import java.util.ArrayList;

import desktop.local.pair.compete.LocalPairCompeteScene;
import desktop.local.pair.cooperate.LocalPairCooperateScene;
import desktop.local.single.LocalSingleScene;

import pulpcore.Stage;
import pulpcore.image.CoreImage;

public class ItemFactory {

	private static ItemFactory itemFactory;

	ArrayList<Item> desktopItemList = new ArrayList<Item>();
	ArrayList<Item> webItemList = new ArrayList<Item>();

	Item single;
	Item doubleCompete;
	Item doubleCooperate;
	Item AICompete;
	Item AICooperate;

	Item Web;
	Item LAN;

	private ItemFactory() {
	}

	public static ItemFactory getItemFactory() {
		if (itemFactory == null) {
			itemFactory = new ItemFactory();
			return itemFactory;
		} else
			return itemFactory;
	}

	public ArrayList<Item> getDesktopItemList() {
		this.initDesktopList();
		return desktopItemList;
	}

	public ArrayList<Item> getItemList(String model) {
		if (model.equals("desktopMode")) {
			return this.getDesktopItemList();
		} else if (model.equals("webModel")) {
			return this.getWebItemList();
		} else
			return null;
	}

	public ArrayList<Item> getWebItemList() {
		this.initWebList();
		return webItemList;
	}

	public void initDesktopList() {

		CoreImage singleImage = CoreImage.load("single.png");
		single = new Item(singleImage, 30, 20, 120, 120, new ItemAction() {
			@Override
			public void do_item_action(int elapsedTime) {
				Stage.pushScene(new LocalSingleScene());
			}
		});

		CoreImage doubleCompeteImage = CoreImage.load("doubleCompete.png");
		doubleCompete = new Item(doubleCompeteImage,  330, 180, 120, 120,
				new ItemAction() {
					@Override
					public void do_item_action(int elapsedTime) {
						Stage.pushScene(new LocalPairCompeteScene());
					}
				});

		CoreImage doubleCooperateImage = CoreImage.load("doubleCooperate.png");
		doubleCooperate = new Item(doubleCooperateImage, 180, 100, 120, 120,
				new ItemAction() {
					@Override
					public void do_item_action(int elapsedTime) {
						Stage.pushScene(new LocalPairCooperateScene());
					}
				});

		desktopItemList.add(single);
		desktopItemList.add(doubleCompete);
		desktopItemList.add(doubleCooperate);
	}

	public void initWebList() {

		CoreImage WebImage = CoreImage.load("Web.png");
		Web = new Item(WebImage, 20, 30, 200, 200, new ItemAction() {
			@Override
			public void do_item_action(int elapsedTime) {

			}
		});

		CoreImage LANImage = CoreImage.load("LAN.png");
		LAN = new Item(LANImage, 250, 30, 200, 200, new ItemAction() {
			@Override
			public void do_item_action(int elapsedTime) {

			}
		});

		webItemList.add(Web);
		webItemList.add(LAN);
	}

}
